package com.zbkj.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zbkj.common.model.client.agent.UserLocation;
import com.zbkj.common.model.client.agent.UserSpecialTopicCategory;
import com.zbkj.service.dao.client.UserSpecialTopicCategoryDao;
import com.zbkj.service.service.UserSpecialTopicCategoryService;
import org.springframework.stereotype.Service;

/**
 * 用户选题类型表 Service 实现类
 * @author: 零风
 * @since: 2024-01-01
 */
@Service
public class UserSpecialTopicCategoryServiceImpl extends ServiceImpl<UserSpecialTopicCategoryDao, UserSpecialTopicCategory> implements UserSpecialTopicCategoryService {

    /**
     * 根据用户ID获取用户定位信息
     * @param userId 用户ID
     * @return UserLocation
     */
    @Override
    public UserSpecialTopicCategory getByUserId(Integer userId) {
        LambdaQueryWrapper<UserSpecialTopicCategory> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserSpecialTopicCategory::getUserId, userId);
        wrapper.eq(UserSpecialTopicCategory::getIsDel, 0);
        wrapper.orderByDesc(UserSpecialTopicCategory::getCreateTime);
        wrapper.last("limit 1");
        return getOne(wrapper);
    }
} 